#include <boost/asio.hpp>
#include <iostream>
using namespace boost::asio;

/*class tcp_server
{
    private:
        tcp::socket connect_socket;
        boost::asio::io_context::io_context& runner;
        
};*/


void handler(const boost::system::error_code& error/*,ip::tcp::resolver::iterator*/)
{

}
int a=0;
void handle_accept(const boost::system::error_code& error)
{
    std::cout<<"handle"<<std::endl;
    a = 1;
}

int main()
{
    boost::asio::io_context io_context;
    boost::asio::ip::tcp::endpoint ep(boost::asio::ip::tcp::v4(),6565);
    boost::asio::ip::tcp::acceptor ac(io_context,ep);
    boost::asio::ip::tcp::socket socket(io_context);
    //bind是真的牛鼻
    ac.async_accept(socket,handle_accept);
    io_context.run();
    while(!a){}
    std::cout<<"out"<<a<<std::endl;
}
/*int main()
{
    //tcp::socket sockets;
    boost::asio::io_context my_io_context;
    ip::tcp::socket TcpSockets(my_io_context);
    boost::asio::ip::tcp::resolver resolver(my_io_context);
    boost::asio::ip::tcp::resolver::query query("www.boost.org", "http");
    ip::tcp::resolver::iterator iter = resolver.resolve(query);
    ip::tcp::resolver::iterator end; // End marker.
    while (iter != end)
    {
        ip::tcp::endpoint endpoint = *iter++;
    }

    boost::asio::async_connect(TcpSockets,iter,end,handler);
}*/